﻿using System;
using System.Collections.Generic;
using System.Text;
using Test.Data;

namespace Test.Examples {
	public class Example2 {
		public Example2() {

			//Create object, and fill data
			DataBase data = new DataBase() {
				Name = "Hello",
				UUID = Guid.NewGuid(),
				Version = new Version(0,0,0,1),
				Tables = new PackageList<DataTable>(),
			};
			data.Tables.Add(new DataTable() {
				Name = "Table 1",
				UUID = Guid.NewGuid(),
			});
			data.Tables.Add(new DataTable() {
				Name = "Table 2",
				UUID = Guid.NewGuid(),
			});
			data.Tables.Add(new DataTable() {
				Name = "Table 3",
				UUID = Guid.NewGuid(),
			});
			
			//Begin editing
			PackageUnit.BeginEdit(data);
			data.Name = "New Name";
			data.UUID = Guid.Empty;

			//Childs
			data.Tables[0].Name = "Table -1";
			data.Tables[1].Name = "Table 0";
			data.Tables[2].Name = "4";

			//Note, current table count = 3
			data.Tables.Clear();
			//current table count = 0
			PackageUnit.CancelEdit(data);//Revert
			//Current table count = 3

		}
	}
}
